package response

//Application app基本信息表
type Sla map[string]interface{}

type History struct {
	ID            uint64 `json:"id" gorm:"column:id"`
	AppID         uint64 `json:"app_id" gorm:"column:app_id"`
	Duration      int64  `gorm:"column:duration" json:"duration,omitempty"`
	DurationCount int64  `json:"duration_count" gorm:"column:durationCount"`
}

type Statistics struct {
	Name string     `json:"name"`
	Data []*ApiData `json:"data"`
}

type SlaStat struct {
	L0 *StatItem `json:"l0"`
	L1 *StatItem `json:"l1"`
	L2 *StatItem `json:"l2"`
	L3 *StatItem `json:"l3"`
	L4 *StatItem `json:"l4"`
	L5 *StatItem `json:"l5"`
}

type StatItem struct {
	Level        int     `gorm:"column:level" json:"level" form:"level"`
	AppCount     int     `gorm:"column:app_count" json:"app_count" form:"app_count"`
	ApiCount     int     `gorm:"column:api_count" json:"api_count"`
	HttpApiCount int     `gorm:"column:http_api_count" json:"http_api_count" form:"http_api_count"`
	ZeusApiCount int     `gorm:"column:zeus_api_count" json:"zeus_api_count" form:"zeus_api_count"`
	QPS          float64 `gorm:"column:qps" json:"qps" form:"qps"`
	HttpQPS      float64 `gorm:"column:http_qps" json:"http_qps" form:"http_qps"`
	ZeusQPS      float64 `gorm:"column:zeus_qps" json:"zeus_qps" form:"zeus_qps"`

	QPSMax     float64 `gorm:"column:qps_max" json:"qps_max" form:"qps_max"`
	HttpQPSMax float64 `gorm:"column:http_qps_max" json:"http_qps_max" form:"http_qps_max"`
	ZeusQPSMax float64 `gorm:"column:zeus_qps_max"  json:"zeus_qps_max" form:"zeus_qps_max"`

	ErrorCount     float64 `gorm:"column:error_count"  json:"error_count" form:"error_count"`
	HttpErrorCount float64 `gorm:"column:http_error_count" json:"http_error_count" form:"http_error_count"`
	ZeusErrorCount float64 `gorm:"column:zeus_error_count" json:"zeus_error_count" form:"zeus_error_count"`

	TotalRequestCount float64 `gorm:"column:total_request_count" json:"total_request_count" form:"total_request_count"`
	ZeusRequestCount  float64 `gorm:"column:zeus_request_count" json:"zeus_request_count" form:"zeus_request_count"`
	HttpRequestCount  float64 `gorm:"column:http_request_count" json:"http_request_count" form:"http_request_count"`

	SLA     float64 `gorm:"column:sla" json:"sla" form:"sla"`
	TP99    float64 `gorm:"column:tp99" json:"tp99" form:"tp99"`
	TP99Max float64 `gorm:"column:tp99_max" json:"tp99_max" form:"tp99_max"`
	TP95    float64 `gorm:"column:tp95" json:"tp95" form:"tp95"`
	TP95Max float64 `gorm:"column:tp95_max" json:"tp95_max" form:"tp95_max"`
}

//声明一个Hero结构体切片类型
type HistorySlice []*History

//切片实现Interface 接口的三个方法
//1.Len() ：返回切片的大小
func (m HistorySlice) Len() int {
	return len(m)
}

//2.Less(i, j int) :决定使用什么规则进行排序
func (m HistorySlice) Less(i, j int) bool {
	return m[i].Duration < m[j].Duration
}

//3.Swap(i, j int) :Less(i, j int)返回true时进行交换
func (m HistorySlice) Swap(i, j int) {
	m[i], m[j] = m[j], m[i]
}

type Metric struct {
	Name string `json:"name"`
	Key  string `json:"key"`
	Show bool   `json:"show"`
}

type GroupSla struct {
	ID       string             `json:"id"`
	Kind     int                `json:"kind"`
	Name     string             `json:"name"`
	Stats    map[string]float64 `json:"stats"`
	Level    int                `json:"level"` // 层级
	ParentID string             `json:"parent_id"`
	GroupNum int
	SlaSum   float64
}
type GroupSlaSlice []*GroupSla

//切片实现Interface 接口的三个方法
//1.Len() ：返回切片的大小
func (m GroupSlaSlice) Len() int {
	return len(m)
}

//2.Less(i, j int) :决定使用什么规则进行排序
func (m GroupSlaSlice) Less(i, j int) bool {
	return m[i].Level > m[j].Level
}

//3.Swap(i, j int) :Less(i, j int)返回true时进行交换
func (m GroupSlaSlice) Swap(i, j int) {
	m[i], m[j] = m[j], m[i]
}

type GroupSlaSlice2 []*GroupSla

//切片实现Interface 接口的三个方法
//1.Len() ：返回切片的大小
func (m GroupSlaSlice2) Len() int {
	return len(m)
}

//2.Less(i, j int) :决定使用什么规则进行排序
func (m GroupSlaSlice2) Less(i, j int) bool {
	return m[i].Name > m[j].Name
}

//3.Swap(i, j int) :Less(i, j int)返回true时进行交换
func (m GroupSlaSlice2) Swap(i, j int) {
	m[i], m[j] = m[j], m[i]
}

type StatGroup struct {
	Name  string  `gorm:"column:dev_group_name" json:"dev_group_name" form:"dev_group_name"`
	ID    string  `gorm:"column:dev_group_id" json:"dev_group_id" form:"dev_group_id"`
	Sla   float64 `gorm:"column:sla"  json:"sla"`
	Tag   uint64  `gorm:"column:tag" json:"tag"`
	Sum   float64 `gorm:"column:sum" json:"sum"`
	Count float64 `gorm:"column:count" json:"count"`
}
